package compile;

/**
 * @author SongJun
 * @description TODO:
 * @date 2021/9/29 15:58
 */
public class CharStream {
    String data;
    int pos = 0;
    int line = 1;
    int col = 0;

    public CharStream(String data) {
        this.data = data;
    }

    char peek(){
        return this.data.charAt(this.pos);
    }

    char next(){
        char ch = this.data.charAt(this.pos++);
        if(ch == '\n'){
            this.line++;
            this.col=0;
        } else {
            this.col++;
        }
        return ch;
    }

    boolean eof(){
        return this.pos >= this.data.length();
    }
}
